<?php

declare(strict_types=1);

namespace Dreamcat\ApiDoc\Utils;

use DreamCat\Array2Class\Utils\FeatureJudge;
use MyCLabs\Enum\Enum;
use ReflectionClass;

/**
 * 枚举辅助类
 * @author vijay
 */
class EnumUtils
{
    /**
     * 判断是否为枚举类
     * @param ReflectionClass $reflectionClass
     * @return bool
     * @codeCoverageIgnore
     */
    public static function isEnumClass(ReflectionClass $reflectionClass): bool
    {
        if ($reflectionClass->isSubclassOf(Enum::class)) {
            return true;
        }
        if (!FeatureJudge::hasEnum()) {
            return false;
        }
        return $reflectionClass->isEnum();
    }
}
